<template>
	<view class="container">
		<!-- 顶部tab -->
		<view class="tab-bar">
			<view :class="selectTab === 0 ? 'select' : ''" @click="handleTabChange({ detail: { current: 0 } })">全部
			</view>
			<view :class="selectTab === 1 ? 'select' : ''" @click="handleTabChange({ detail: { current: 1 } })">邀请
			</view>
			<view :class="selectTab === 2 ? 'select' : ''" @click="handleTabChange({ detail: { current: 2 } })">待开工
			</view>
			<view :class="selectTab === 3 ? 'select' : ''" @click="handleTabChange({ detail: { current: 3 } })">进行中
			</view>
			<view :class="selectTab === 4 ? 'select' : ''" @click="handleTabChange({ detail: { current: 4 } })">已完成
			</view>
		</view>
		<view class="hg-30"></view>
		<!-- 主体内容 -->
		<view class="list">
			<!-- 工作信息 -->
			<u-swipe-action>
				<u-swipe-action-item v-show="show1" v-for="(item,index) in jobList" :key="item.id"
					:options="[{text: '删除',style: {backgroundColor: '#f56c6c'}}]"
					@click="handleDeleteLine(item.id,item.status)">
					<view class="job-info" @click.stop="handleOpenPage(item.id)">
						<view>
							<text>{{item.taskName}}</text>
							<!-- 状态栏 -->
							<view class="status"
								:class="item.status === 1 ? 'waitEmployer' : item.status === 7 ? 'waitEmployee' : item.status === 2 ? 'waitWork' : (item.status === 3||item.status === 4) ? 'inProgress' : item.status === 5 ? 'finish' : item.status === 0 ? 'cancel' : 'comment' ">
								{{ item.status === 1 ? '待确认接单' : item.status === 7 ? '等待雇员同意' : item.status === 2 ? '待开工' : item.status === 3 ? '进行中' : item.status === 5 ? '已完成' : item.status === 0 ? '已取消' : item.status === 4 ? '等待雇主付款' : item.status === 9 ? '待同意' : '等待雇主开工确认' }}
							</view>
						</view>
						<view>
							<image src="/static/icon1/14.png" mode="aspectFill"></image>
							<text>{{ item.status === 0  ? getShowAdd(item.taskAddress) : item.status === 5  ? getShowAdd(item.taskAddress) : item.taskAddress}}</text>
						</view>
						<view>
							<text class="money" :style="{color: item.vipFlag ? '#4E9800' : '#FF650C'}">
								{{ item.taskType===0 ? (item.rewardY+item.subsidyY) : item.rewardY}}{{ item.taskType===0 ? '元/小时' : item.taskType===1 ? '元/件' : item.taskType===2 ? '元/天' : ''}}<text
									v-if="item.floorsstr==1"
									class="floorsstr-view">保底{{item.floorsAmount/100}}元/小时</text>
							</text>
							<text style="display: none;" class="money"
								:style="{color: item.vipFlag ? '#4E9800' : '#FF650C'}" v-if="item.taskType==1">
								{{ item.floorsAmountY }}元/小时 </text>
						</view>
						<!-- 补贴 -->
						<view class="subsidy" v-if="item.vipFlag && item.subsidy && item.taskType">补: {{item.subsidyY}}元
						</view>
						<!-- 按钮 -->
						<view class="buttons" v-if="item.status != 0 && item.status != 4">
							<view
								@click.stop="handleOpenModal(0, item.status, item.id,null,null,null,null,null,null,null,null,item.isExpel)"
								class="button"
								v-if="item.status != 5 && item.status != 9 && item.status != 1 && item.isExpel!=false">
								{{item.status == 7 ? '拒绝' : item.isExpel==true?'辞工':'取消'}}
							</view>
							<view @click.stop="handleOpenModal(0, item.status, item.id)" class="button"
								v-if="item.status != 5 && item.status != 9 && item.status == 1">
								{{item.status == 7 ? '拒绝' : ('取消'+invitationCountDown(item.createTime,item.id,1)+countDown[countDown.indexOf(item.id)+1]) }}
							</view>
							<view
								@click.stop="handleOpenModal(1, item.status, item.id , item.taskType, (item.reward+item.subsidy), item.startTime,item.taskStartTime,item.taskEndTime,item.levelsd,item.floorsstr,item.floorsAmount,null,item.createBy,item.avatar,item)"
								class="button"
								v-if="(item.status==5&&(item.isEmployeeEvaluate==0)) || (item.status == 2) || (item.status == 3)&&item.isExpel!=true || (item.status == 7) || (item.status == 1)"
								:style="{background: item.status == 7 ? '#4E9800' : '#F39B19', border: item.status == 7 ? '#4E9800' : '#F39B19'}">
								{{item.status == 7 ? ('同意'+invitationCountDown(item.createTime,item.id,2)+countDown[countDown.indexOf(item.id)+1]) : item.status == 2? '开工': item.status == 9 ? '待同意' : item.status == 3 ? '收工' : (item.status == 5 && (item.isEmployeeEvaluate==0)) ? '评价' : item.isOldStaff||item.disturbstatus==1?'直接接单':item.isConfirm?'确认接单':'拨打电话'}}
							</view>
						</view>
					</view>
				</u-swipe-action-item>
			</u-swipe-action>
		</view>
		<view class="mask" v-if="isShowIncome" @click="close_ShowIncome()">
			<view class="income-content" @click.stop="">
				<view class="income-content-text">确认收工</view>
				<view class="income-content-text-title">
					<text class="income-content-text-danjai">计件单价</text>
					<text class="income-content-text-jiage">{{income_reward}}元/件</text>
				</view>
				<view class="income-content-text-title">
					<text class="income-content-text-danjai">完成件数</text>
					<view class="income-content-text-input-view">
						<input class="income-content-text-input" type="number" v-model="count" @input="handleInput" />件
					</view>
				</view>
				<view class="income-content-text-title">
					<text class="income-content-text-danjai">计件工资</text>
					<text class="income-content-text-zongji"
						:style="{color:isShowBaodi_reward?'#000000':'#FF4600'}">{{income_money}}元</text>
				</view>
				<view class="income-content-text-title" v-if="isShowBaodi_reward">
					<text class="income-content-text-danjai">保底工资</text>
					<text class="income-content-text-zongji">{{baodi_reward}}元</text>
				</view>
				<view class="income-content-baodi-view" v-if="isShowBaodi_reward">低于保底金额，使用保底工资进行结算</view>
				<view class="income-content-text-button">
					<view class="income-content-text-button-cancel" @click="close_ShowIncome()">取消</view>
					<view class="income-content-text-button-ok" @click="income_click()">确认</view>
				</view>
			</view>
		</view>
		<!-- 加载 -->
		<uni-load-more :status="hasFlag ? 'loading' : 'noMore'"></uni-load-more>
		<!-- 弹窗 -->
		<modal :isShowModal="isShowModal" :modalStytle="modalStytle" :unitPrice="unitPrice" :workTime="workTime"
			:workPrice="workPrice" :jobType="jobType" :jobleve="jobleve" @handleLeft="handleLeft"
			@handleRight="handleRight" @input="handleInput" :titleContect="titleContect" :middleContext="middleContext"
			:leftContext="leftContext" :rightContext="rightContext" :contentColor="contentColor"
			:contentsColor="contentsColor"></modal>
		<sealModel v-if="isShowSealAlert" :day="sealDay" @handleLeft="isShowSealAlert=false"
			@handleRight="handleRight()"></sealModel>
		<pingjia v-if="isShowpingjia" @close="closePj()" :userList="pj_user_list"></pingjia>
		<u-modal content="删除订单后将不能恢复，是否确认删除？" :show="show2" showCancelButton width="580rpx" closeOnClickOverlay
			confirmColor="#F39B19" cancelColor="#ABABAB" @confirm="confirm" @cancel="cancel"></u-modal>
	</view>
</template>
<script>
	import warningPromptBanner from '@/components/warningPromptBanner/warningPromptBanner'
	import format from '@/libs/day-format.js'
	import sealModel from '@/components/xjbg/sealModel.vue'
	import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue'
	import modal from '@/components/modal/modal.vue'
	import placesMap from '@/libs/place-map.js'
	import Voice from '@/libs/QS-baiduyy.js'
	import AudioPlayer from 'untils/audio-player.js';
	import {
		isToDay,
		getSealDay,
		isResidueTimeByMinute,
	} from '@/libs/unit.js'
	import phoneLimite from '@/libs/function/phoneLimite.js' //判断是否有拨打电话权限
	export default {
		components: {
			uniLoadMore,
			modal,
			sealModel,
			warningPromptBanner,
		},
		data() {
			return {
				// isFinishModal: false,
				handleIsStop: true, // 是否允许切换，网速太慢时
				toDay: '', //当前时间
				jobleve: 0,
				x_hours_no_order: '', //雇员取消x小时内不可接单
				order_user_cancel_cut_integrity: '', //雇员取消订单扣除诚信值
				place: {}, //省市区
				street: {}, //街道
				status: 2, //雇主打钱后的状态
				hasFlag: true, //是否加载完成
				timer: [], //定时器
				selectTab: 0, // 当前选中的tabbar索引 index
				button: 1, //按钮类型
				orderId: '', //点中订单的id
				clickStatus: 0, //工作状态
				jobType: 0, //工作类型0计时工，1：计天工，2计件工
				count: '', //收工雇员输入的计件件数
				modalStytle: 3, //0-left-text,1-two-line,2-hasInput, 3-middle-context
				isShowModal: false, //是否显示弹框
				titleContect: '', //弹框标题
				middleContext: '', //弹框中间的内容
				unitPrice: 0, //计件单价
				workTime: '0', //计时工作时间
				workPrice: 0, //工作单价
				leftContext: '取消', //弹框按钮左边的内容
				rightContext: '确认', //弹框按钮右边的内容
				jobList: [],
				requestObj: {
					pageNum: 0,
					pageSize: 10,
					status: '',
					statusIn: '',
					taskId: '',
				},
				isEmployeeEvaluate: 0, //0雇员还没有评价雇主,1评价了
				countDown: [],
				quxiaoFlag: 1,
				isShowIncome: false,
				income_money: 0,
				income_reward: 0,
				baodi_reward: 0,
				isShowBaodi_reward: false,
				is_baodi_work: false,
				sealDay: 3, //禁封天数
				isShowSealAlert: false,
				expel_time: 30,
				contentColor: '',
				contentsColor: '',
				isShowpingjia: false,
				pj_user_list: [],
				currentTaskReceived: [],
				show1: true,
				show2: false,
				delOrderId: '',
				nowTime: 0
			}
		},
		computed: {
			'isFinishModal': function() {
				return this.$store.state.isFinishModal
			}
		},
		methods: {
			// 左滑删除订单
			handleDeleteLine(orderId, status) {
				this.delOrderId = orderId
				if (status == 0) {
					this.confirm()
				} else {
					this.show2 = true
				}
			},
			async getLocatime() {
				let res = await this.$fetch(this.$api.get_locatime, {}, 'GET')
				this.nowTime = res.data
				let day_0 = new Date(this.nowTime);
				day_0.setDate(day_0.getDate());
				this.toDay = day_0.format("yyyy-MM-dd hh:mm:ss")
			},
			deletMessageLine(orderId) {
				this.refresh()
				// this.show1 = false
			},
			async confirm() {
				let res = await this.$fetch(this.$api.order_list_delete, {
					orderId: this.delOrderId
				}, 'DELETE')
				if (res.code) return uni.showToast({
					title: res.msg,
					icon: 'none'
				})
				this.refresh()
				this.delOrderId = ''
				// this.show1 = false
				this.show2 = false
			},
			cancel() {
				// this.refresh()
				// this.show1 = true
				this.show2 = false
			},
			//获取展示定位地址
			getShowAdd(add) {
				add = add.split('·')
				return add.splice(0, 2).join('·')
			},
			//打开弹框isEmployeeEvaluate
			async handleOpenModal(button, status, orderId, taskType, reward, startTime, taskStartTime, taskEndTime,
				levelsd, floorsstr, floorsAmount, isExpel, createBy, bossPhoto, item) {
				/* console.log('button',button, 'status',status, 'taskType', taskType) */
				this.orderId = orderId
				this.button = button
				this.clickStatus = status
				this.jobType = taskType
				if (status != 5) {
					this.isShowModal = true
					if (button == 1 && status == 7) { //同意
						this.getData()
						this.modalStytle = 0
						this.titleContect = '确认订单'
						this.middleContext = '接单成功后，如果取消订单，会导致' + this.sealDay + '天不可再次接单。'
						this.leftContext = '取消'
						this.rightContext = '确认'
					} else if (button == 0 && status == 7) { //拒绝
						this.modalStytle = 3
						this.titleContect = '拒绝邀请'
						this.middleContext = '是否拒绝邀请'
						this.leftContext = '取消'
						this.rightContext = '确认'
					} else if (button == 1 && status == 2) { //开工
						if (item.isCheck == 1) {
							this.handleOpenPage(item.id)
							this.isShowModal = false
							return
						}
						this.modalStytle = 3
						this.titleContect = '确认订单'
						this.middleContext = '是否开工'
						this.leftContext = '取消'
						this.rightContext = '确认'
					} else if (button == 0 && status != 7 && status != 1 && isExpel != true) { //所有取消 除了1
						this.isShowModal = false
						this.isShowSealAlert = true
						// this.getData()
						// this.modalStytle = 0
						// this.titleContect = '取消订单'
						// this.middleContext = '雇主正在等待您的开工，取消任务将会对您的账号进行限制！'
						// this.leftContext = '取消'
						// this.rightContext = '确认'
					} else if (button == 0 && status != 7 && status != 1 && isExpel == true) { //辞工
						// this.getData()
						this.modalStytle = 98
						this.titleContect = '辞工'
						this.middleContext = '你将无责辞工，#但不会被结算工资，请谨慎处理#'
						this.leftContext = '取消'
						this.rightContext = '确认'
						this.contentColor = '#787878'
						this.contentsColor = '#FE4B28'
					} else if (button == 1 && status == 3) { //收工
						this.getToday() //计算工作时间
						//计件收工
						if (taskType == 1) {
							// this.modalStytle = 2
							// this.unitPrice = reward.divide(100)
							this.isShowModal = false
							this.isShowIncome = true
							this.income_reward = reward / 100
							if (floorsstr == 1) {
								this.is_baodi_work = true
								let start = new Date(startTime.replace(/-/g, '/'))
								let end = this.nowTime
								let diff = end - start.getTime();
								let sec = diff / 1000 / 60 / 60;
								this.baodi_reward = Math.floor((floorsAmount / 100) * sec * 100) / 100
								// console.log('dsadsadsa', this.baodi_reward)
							} else {
								this.is_baodi_work = false
								this.baodi_reward = 0
								this.isShowBaodi_reward = false
							}
							return
							/* 	console.log('this.modalStytle',this.modalStytle, 'this.unitPrice',this.unitPrice, ) */
							//计时收工
						} else {
							this.modalStytle = 1
							this.calWorkTime(startTime) //计时工作时间
							this.workPrice = reward.divide(100) //工作单价
						}
						if (levelsd == 2) { //判断是否二级雇主
							if (taskEndTime > this.toDay) { //结束时间大于当前时间
								this.jobleve = 1
							}
						}
						this.titleContect = '确认收工'
						this.leftContext = '取消'
						this.rightContext = '确认'
					} else if (button == 0 && status == 1) {
						/* console.log('取消订单') */
						this.modalStytle = 3
						this.titleContect = '取消订单'
						this.middleContext = this.quxiaoFlag == 1 ? '订单取消后无法重复报名，确认取消吗？' : this.quxiaoFlag == 2 ?
							'订单取消次数将达上限，确认取消吗？' : '订单取消次数已达上限，确认取消吗？'
						this.leftContext = '取消'
						this.rightContext = '确认'
					} else if (button == 1 && status == 1) {
						this.currentTaskReceived = [item.isConfirm, item.isOldStaff, item.disturbstatus, item
							.telephone,
							orderId, item.taskId
						]
						this.modalStytle = 3
						this.titleContect = '确认订单'
						this.middleContext = item.isOldStaff || item.disturbstatus == 1 ? '是否直接接单' : !item.isConfirm ?
							'是否拨打电话' : '是否确认接单'
						this.leftContext = '取消'
						this.rightContext = '确认'
					}
					//this.isShowModal = true
				} else {
					let imPath = uni.getStorageSync('imgPath')
					let res = await this.$fetch(this.$api.order_detail, {
						orderId: orderId
					}, 'POST')
					setTimeout(() => {
						this.pj_user_list = [res.data.taskUser.updateBy, imPath + bossPhoto, orderId, 1, item]
						this.isShowpingjia = true
					}, 100)
					// uni.redirectTo({
					// 	url: '/pages/comment/comment?orderId=' + orderId + '&type=' + 1
					// })
				}
			},
			//今天的时间
			getToday() {
				this.getLocatime()
			},
			// 刷新
			refresh() {
				this.jobList = []
				this.hasFlag = true
				this.requestObj.pageNum = 0
				this.requestObj.pageSize = 10
				this.order_list()
			},
			//计算工作时间
			calWorkTime(startTime) {
				let Time = new Date(startTime.replace(/-/g, '/'));
				let timestemp = Time.getTime(); //开工时间
				let Timeday = new Date(this.toDay.replace(/-/g, '/'));
				let timestempday = Timeday.getTime(); //当前时间
				/* console.log(timestemp, '~~~~~~~~',timestempday) */
				let xjian = (timestempday - timestemp) / 1000 / 60
				/* 	console.log(xjian, '~~~~~~~~') */
				this.workTime = xjian.toFixed(2)
			},
			//弹框左键
			handleLeft() {
				this.isShowModal = false
				if (this.button == 1 && this.clickStatus == 5) { //休息
					/* 	console.log('休息') */
					uni.switchTab({
						url: '/pages/tabBar-2/tabBar-2'
					})
				}
				this.$store.commit('isFinishModalChange', false)
			},
			// 获取用户输入的件数
			handleInput() {
				// this.count = value
				if (this.count > 100000) {
					uni.showToast({
						title: '最大件数不能大于10万件哦',
						icon: 'none'
					})
					this.$nextTick(function() {
						this.count = 100000
					})
				} else {
					this.count ? this.income_money = Math.floor((parseFloat(this.count) * parseFloat(this.income_reward)) *
						100) / 100 : 0
					if (this.is_baodi_work) {
						this.isShowBaodi_reward = this.baodi_reward > this.income_money
					}
				}
			},
			// 获取用户当前的经纬度并且开工
			getLocationAndWork() {
				return new Promise((resolve) => {
					uni.getLocation({
						type: 'gcj02',
						success: async (res) => {
							uni.setStorageSync('location', [res.latitude, res.longitude]);
							let resObj = await this.$fetch(this.$api.order_user_start_worker, {
								orderId: this.orderId,
								lat: res.latitude,
								lng: res.longitude
							}, 'POST')
							if (resObj.code) {
								uni.showToast({
									title: resObj.msg,
									icon: 'none'
								})
								resolve(false);
								return;
							}
							uni.setStorageSync('receivedTaskStartTime', '')
							resolve(true);
						},
						fail: async () => {
							await this.getLocationAndWork();
						}
					})
				})
			},
			//弹框右键
			async handleRight() {
				this.isShowModal = false
				uni.setStorageSync('shuaxin', true)
				if (this.button == 0 && this.clickStatus == 7) { //拒绝
					let res = await this.$fetch(this.$api.order_user_refuse_invite, {
						orderId: this.orderId
					}, 'POST')
					if (res.code) return uni.showToast({
						title: res.msg,
						icon: 'none'
					})
					uni.$emit('closeWorking', {})
					uni.$emit('closeDaikgong', {})
				} else if (this.button == 0 && this.clickStatus != 7 && this.clickStatus != 1) { //取消
					// console.log('~~~~',this.orderId)
					let res = await this.$fetch(this.$api.order_user_cancel, {
						orderId: this.orderId
					}, 'POST')
					if (res.code) return uni.showToast({
						title: res.msg,
						icon: 'none'
					})
					uni.$emit('closeWorking', {})
					uni.$emit('closeDaikgong', {})
					if (uni.getStorageSync('checked1')) {
						Voice("您的任务已取消")
					}
					uni.setStorageSync('receivedTaskStartTime', '')
					setTimeout(() => {
						uni.navigateTo({
							url: '/pages/cancellationOrder/cancellationOrder?orderId=' + this.orderId
						})
					}, 800)
					this.isShowSealAlert = false
				} else if (this.button == 1 && this.clickStatus == 2) { //开工
					await this.getLocationAndWork();
					uni.$emit('openWorking', {})
					uni.$emit('closeDaikgong', {})
				} else if (this.button == 1 && this.clickStatus == 3) { //收工
					if (this.jobType == 1 && this.count == 0) return uni.showToast({
						title: '请输入件数~',
						icon: 'none'
					})
					let res = await this.$fetch(this.$api.order_user_end, {
						orderId: this.orderId,
						status: 1,
						count: parseInt(this.count)
					}, 'POST')
					if (res.code) return uni.showToast({
						title: res.msg,
						icon: 'none'
					})
					uni.$emit('closeWorking', {})
					uni.$emit('closeDaikgong', {})
					//请与雇主当面收工，结算工资后，再离开现场。
					if (uni.getStorageSync('checked1')) {
						Voice("您已收工，结算工资后再离开现场")
					}
				} else if (this.button == 1 && this.clickStatus == 7) { //同意
					let res = await this.$fetch(this.$api.order_user_confirm_invite, {
						orderId: this.orderId
					}, 'POST')
					if (res.code) return uni.showToast({
						title: res.msg,
						icon: 'none'
					})
					uni.$emit('openDaikgong', {})
					uni.$emit('closeWorking', {})
				} else if (this.button == 1 && this.clickStatus == 5) { //继续接单
					this.$store.commit('isFinishModalChange', false)
					uni.switchTab({
						url: '/pages/index/index'
					})
				} else if (this.clickStatus == 1) { //取消订单或者确认订单
					this.currentTaskReceived[1] = false
					let checkStatus = this.button == 1 ? 2 : 0
					if (checkStatus == 0) {
						this.quxiaoFlag++
						uni.setStorageSync('quxiaoFlag', [uni.getStorageSync('date'), this.quxiaoFlag])
					}
					if (checkStatus == 0 || this.currentTaskReceived[0] || this.currentTaskReceived[1] || this
						.currentTaskReceived[2] == 1) {
						/* 	console.log('取消订单或者确认订单', checkStatus,this.orderId) */
						let res = await this.$fetch(this.$api.apply_check, {
							orderId: this.orderId,
							checkStatus: checkStatus
						}, 'POST')
						if (res.code) return uni.showToast({
							title: res.msg,
							icon: 'none'
						})
						uni.setStorageSync('hasUnconfirm', 0)
						if (checkStatus == 0) {
							uni.navigateTo({
								url: '/pages/cancellationOrder/cancellationOrder?orderId=' + this.orderId
							})
						}
						/* 	console.log('获取接单语音提醒状态~~~~~我的零工页——取消或确认订单',uni.getStorageSync('hasUnconfirm')) */
					} else if (!this.currentTaskReceived[0]) {
						this.currentTaskReceived[0] = true
						let receivedInfoList = uni.getStorageSync('ReceivedInfo') ? uni.getStorageSync(
							'ReceivedInfo') : []
						if (receivedInfoList.length > 0) {
							receivedInfoList.forEach((v, index) => {
								if (v[0] == this.currentTaskReceived[5]) {
									receivedInfoList[index][1] = true
								}
							})
							uni.setStorageSync('ReceivedInfo', receivedInfoList)
						}
						this.phone_bind_middle_number(this.currentTaskReceived[3], this.currentTaskReceived[4])
					} else {
						uni.showToast({
							title: 'error',
							icon: 'none'
						})
					}
				}
				this.refresh()
			},
			//获取虚拟电话
			async phone_bind_middle_number(telephone, id) {
				let res = await this.$fetch(this.$api.phone_bind_middle_number, {
					phone: telephone,
					orderId: id
				}, 'POST', 'form')
				console.log('获取虚拟电话res~~~~~~', res, telephone)
				let phoneNumber
				if (res.code != '500') {
					phoneNumber = (res.data.middleNumber && res.data.overTime != '1000') ? res.data.middleNumber :
						telephone
				} else {
					phoneNumber = telephone
				}
				phoneLimite(phoneNumber)
			},
			// 更改类目
			handleTabChange({
				detail: {
					current
				}
			}) {
				if (this.selectTab === current) return
				this.selectTab = current
				/* 	console.log('选中this.selectTab', this.selectTab) */
				if (this.selectTab == 1) {
					this.requestObj.status = 7
				} else if (this.selectTab == 2) {
					this.requestObj.status = 2
				} else if (this.selectTab == 3) {
					this.requestObj.status = 3
				} else if (this.selectTab == 4) {
					this.requestObj.status = 5
				} else {
					this.requestObj.status = ''
				}
				this.refresh()
			},
			//打开订单详情页
			handleOpenPage(id) {
				uni.navigateTo({
					url: '/pages/order-detail/order-detail?id=' + id
				})
			},
			//获取我的零工
			async order_list() {
				if (!this.hasFlag) return // 说明已经没有更多啦

				++this.requestObj.pageNum
				// 是否允许切换，
				if (!this.handleIsStop) return uni.showToast({
					title: '你点击得太快啦~',
					icon: 'none'
				}) // 说明上一条请求结果未返回
				this.handleIsStop = false
				// console.log('this.requestObj', this.requestObj)
				let res = await this.$fetch(this.$api.order_list, this.requestObj, 'POST')
				if (res.code) return uni.showToast({
					title: res.msg,
					icon: 'none'
				})
				let receivedInfoList = uni.getStorageSync('ReceivedInfo') ? uni.getStorageSync('ReceivedInfo') : []
				/* console.log(res) */
				// 将金额除以100，单位变为元
				res.rows.forEach(item => {
					item.rewardY = item.reward.divide(100)
					item.subsidyY = item.subsidy.divide(100)
					item.floorsAmountY = item.floorsAmount.divide(100)
					//startTime 工作开始时间 status 进行中
					if (item.status == 3) {
						item.isExpel = this.expel_time > (isResidueTimeByMinute(item.startTime, this.nowTime) *
							-1)
					}
					if (item.status == 1 && receivedInfoList.length > 0) {
						receivedInfoList.forEach(v => {
							if (v[0] == item.taskId) {
								if (this.currentTaskReceived.length != 0) {
									item.isConfirm = this.currentTaskReceived[5] == item.taskId ? this
										.currentTaskReceived[0] : v[1]
								} else {
									item.isConfirm = v[1]
								}
								item.isOldStaff = v[2]
							}
						})
					}
				})
				uni.stopPullDownRefresh()
				// 是否允许切换
				this.handleIsStop = true
				this.jobList = [...this.jobList, ...res.rows]
				// console.log('this.jobList', this.jobList)
				this.hasFlag = this.requestObj.pageSize * this.requestObj.pageNum < res.total
			},
			// 配置数据
			async getData() {
				let res4 = await this.$fetch(this.$api.property_list_by_type, {
					type: 1
				}, 'POST')
				// 雇员取消x小时内不可接单
				uni.setStorageSync('x_hours_no_order', res4.data.x_hours_no_order)
				// 雇员取消订单扣除诚信值
				uni.setStorageSync('order_user_cancel_cut_integrity', res4.data.order_user_cancel_cut_integrity)
				// 雇主取消任务扣除诚信值
				uni.setStorageSync('task_user_cancel_cut_integrity', res4.data.task_user_cancel_cut_integrity)
				this.order_user_cancel_cut_integrity = uni.getStorageSync('order_user_cancel_cut_integrity')
				this.x_hours_no_order = uni.getStorageSync('x_hours_no_order')
			},
			// 获取我的零工（雇员）
			async order_list_voice() {
				let requestObj = {
					pageNum: 1,
					pageSize: 5,
					status: '1',
					statusIn: '',
					taskId: '',
				}
				let res = await this.$fetch(this.$api.order_list, requestObj, 'POST')
				if (res.code) return uni.showToast({
					title: res.msg,
					icon: 'none'
				})
				/* 	console.log('获取我的零工res', res) */
				if (res.total == 0) {
					uni.setStorageSync('hasUnconfirm', 0)
				}
				/* console.log('app我的零工页面~~~~~~~——语音播报信息', uni.getStorageSync('hasUnconfirm'),uni.getStorageSync('token')) */
			},
			//拒绝邀请
			async refuseInvite(orderId) {
				let res = await this.$fetch(this.$api.order_user_refuse_invite, {
					orderId: orderId
				}, 'POST')
				if (res.code) return uni.showToast({
					title: res.msg,
					icon: 'none'
				})
			},
			//取消订单
			async quxiaoDingdan(orderId) {
				let res = await this.$fetch(this.$api.apply_check, {
					orderId: orderId,
					checkStatus: 0
				}, 'POST')
				if (res.code) return uni.showToast({
					title: res.msg,
					icon: 'none'
				})
			},
			//倒计时
			invitationCountDown(time, orderId, status) {
				let date = new Date(time.replace(/-/g, '/'))
				let time1 = Date.parse(date) / 1000
				let time2 = time1 + (status == 2 ? 900 : status == 1 ? 900 : 0)
				let time3 = Date.parse(new Date()) / 1000
				let time4 = (time2 - time3)
				let time5 = ''
				if (!this.timer.includes(orderId)) {
					this.timer[this.timer.length] = orderId
					this.countDown.push(orderId, '')
					this.timer[this.timer.length] = setInterval(() => {
						time4 = time4 - 1
						time5 = ((Math.floor(time4 / 60 % 60) < 10 ? '0' + Math.floor(time4 / 60 % 60) : Math
							.floor(time4 / 60 % 60)) + ':' + (Math.floor(time4 % 60) < 10 ? '0' + Math
							.floor(time4 % 60) : Math.floor(time4 % 60)))
						if ((Math.floor(time4 / 60 % 60)) <= 0 && (Math.floor(time4 % 60)) <= 0) {
							//console.log(Math.floor(time4 / 60 % 60))
							clearInterval(this.timer[this.timer.indexOf(orderId) + 1])
							this.estimateExecute(status, orderId)
							return
						}
						this.countDown.splice(this.countDown.indexOf(orderId) + 1, 1, time5)
					}, 1000)
				}
				return ' '
			},
			//判断实行什么方法
			estimateExecute(status, orderId) {
				switch (status) {
					case 1:
						this.quxiaoDingdan(orderId)
						break;
					case 2:
						this.refuseInvite(orderId)
						break;
					default:
						break;
				}
			},
			income_click() {
				if (!this.count || this.count[0] == '0') {
					uni.showToast({
						title: '请正确输入件数后点击确认',
						icon: 'none'
					})
				} else {
					this.handleRight()
					this.close_ShowIncome()
				}
			},
			close_ShowIncome() {
				this.isShowIncome = false
				this.count = ''
				this.baodi_reward = 0
				this.isShowBaodi_reward = false
				this.income_money = 0
			},
			closePj() {
				this.isShowpingjia = false
				this.refresh()
			},
		},
		onLoad() {
			this.place = placesMap()
			this.street = uni.getStorageSync('street')
			if (uni.getStorageSync('quxiaoFlag')) {
				this.quxiaoFlag = isToDay(uni.getStorageSync('quxiaoFlag')[0]) ? uni.getStorageSync('quxiaoFlag')[1] : 1
			}
			getSealDay().then((v) => {
				this.sealDay = v
			})
			this.expel_time = parseInt(uni.getStorageSync('property_list_by_type').staff_expel_time)
		},
		onShow() {
			this.getLocatime()
			// console.log('this.$store.state.isFinishModal', this.$store.state.isFinishModal)
			if (this.$store.state.isFinishModal) {
				this.clickStatus = 5
				this.modalStytle = 0
				this.titleContect = '完成工作'
				this.middleContext = '您已经出色地完成了本次工作，是否继续接单工作？'
				this.leftContext = '我要休息'
				this.rightContext = '继续接单'
				this.isShowModal = true
			}
			this.refresh()
			this.getData()
			this.order_list_voice()
		},
		onNavigationBarButtonTap(e) {
			uni.navigateTo({
				url: '/pages/app-employer/my-employee/my-blackList'
			})
		},
		onUnload() {
			console.log('清除计时器')
			if (this.timer.length) {
				console.log(this.timer)
				this.timer.forEach((v, index) => {
					if (index % 2 != 0) {
						clearInterval(v)
					}
				})
			}
		},
		onBackPress(options) {
			uni.setStorageSync('shuaxin', true)
		},
		onReachBottom() {
			// console.log('页面到底部了')
			this.order_list()
		},
		onPullDownRefresh() {
			//监听用户下拉动作，一般用于下拉刷新
			this.refresh()
		},
	}
</script>
<style lang="less" scoped>
	.container {

		// overflow: hidden;
		&>.tab-bar {
			z-index: 99;
			position: fixed;
			display: flex;
			height: 90rpx;
			background-color: #FFFFFF;
			box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.03);

			&>view {
				display: flex;
				width: 20vw;
				height: 90rpx;
				justify-content: center;
				align-items: center;
				color: rgba(64, 33, 16, 0.50);
			}

			&>.select {
				display: flex;
				justify-content: center;
				align-items: center;
				position: relative;
				font-weight: bold;
				color: #F39B19;

				&::before {
					content: "";
					position: absolute;
					left: 50rpx;
					bottom: 0;
					width: 50rpx;
					height: 4rpx;
					background: #F39B19;
					border-radius: 1px;
				}
			}
		}

		&>.list {
			margin-top: 90rpx;

			.job-info {
				position: relative;
				display: flex;
				flex-direction: column;
				background-color: #FFFFFF;
				padding: 30rpx;

				&>view {
					display: flex;
				}

				&>view:nth-child(1) {
					justify-content: space-between;
					margin-bottom: 20rpx;

					&>text {
						height: 48rpx;
						font-weight: bold;
						font-size: 17px;
						letter-spacing: 0;
					}

					&>.status {
						font-size: 12px;

						&.waitEmployer,
						&.waitEmployee,
						&.waitWork,
						&.inProgress {
							color: #F39B19;
						}

						&.cancel {
							color: rgba(64, 33, 16, 0.5);
						}

						&.finish,
						&.comment {
							color: #4E9800;
						}
					}
				}

				&>view:nth-child(2) {
					height: 34rpx;
					display: flex;
					margin-bottom: 30rpx;
					font-size: 12px;
					color: rgba(64, 33, 16, 0.70);
					letter-spacing: 0;

					&>image {
						align-self: center;
						width: 26rpx;
						height: 30rpx;
						margin-right: 10rpx;
					}

					&>text {
						// border: 1px solid #000000;
						width: 650rpx;
					}
				}

				&>view:nth-child(3) {

					// border: 1px solid #000000;
					&>.money {
						margin-right: 20rpx;
						// height: 48rpx;
						font-weight: bold;
						font-size: 17px;
						color: #FF650C;
						letter-spacing: 0;
					}
				}

				&>.subsidy {
					font-weight: bold;
					font-size: 17px;
					color: #4E9800;
				}

				&::after {
					content: "";
					position: absolute;
					bottom: 0rpx;
					width: 720rpx;
					height: 2rpx;
					background: #F2F2F2;
				}

				&>.buttons {
					align-self: flex-end;

					&>.button {
						width: 160rpx;
						height: 60rpx;
						border-radius: 35rpx;
						display: flex;
						align-items: center;
						justify-content: center;

						&:active {
							opacity: 0.7;
						}
					}

					.button:nth-child(1) {
						height: 56rpx;
						border: 1px solid rgba(64, 33, 16, 0.50);
						color: rgba(64, 33, 16, 0.50);
					}

					.button:nth-child(2) {
						margin-left: 30rpx;
						color: #FFFFFF;
					}
				}
			}
		}
	}

	.floorsstr-view {
		width: 184rpx;
		height: 34rpx;
		background: #EFF6E7;
		border-radius: 4rpx;
		font-size: 24rpx;
		font-weight: 500;
		color: #599E10;
		line-height: 24rpx;
		margin-left: 12rpx;
		padding: 5rpx 12rpx;
	}

	.mask {
		background-color: rgba(0, 0, 0, .5);
		width: 100vw;
		height: 100vh;
		position: fixed;
		top: 0;
		left: 0;
		display: flex;
		justify-content: center;
		align-items: center;
		z-index: 998;
	}

	.income-content {
		width: 600rpx;
		// height: 480rpx;
		background: #FFFFFF;
		border-radius: 12rpx;
		display: flex;
		flex-direction: column;
		align-items: center;
	}

	.income-content-text {
		font-size: 36rpx;
		font-weight: bold;
		color: #000000;
		margin: 60rpx 0;
	}

	.income-content-text-title {
		width: 528rpx;
		display: flex;
		flex-direction: row;
		justify-content: flex-start;
		align-items: center;
		margin-bottom: 32rpx;
	}

	.income-content-text-danjai {
		font-size: 32rpx;
		font-weight: 500;
		color: #7F7F7F;
		margin-right: 35rpx;
	}

	.income-content-text-jiage {
		font-size: 32rpx;
		font-weight: 500;
		color: #000000;
	}

	.income-content-text-input {
		width: 140rpx;
		height: 30rpx;
		margin-left: 23rpx;
	}

	.income-content-text-input-view {
		width: 223rpx;
		height: 60rpx;
		border: 1px solid #787878;
		border-radius: 4rpx 0px 0px 4rpx;
		display: flex;
		flex-direction: row;
		align-items: center;
		font-size: 32rpx;
		font-weight: 500;
		color: #000000;
		line-height: 60rpx;
	}

	.income-content-text-zongji {
		font-size: 32rpx;
		font-weight: 500;
		color: #FF4600;
	}

	.income-content-text-button {
		width: 600rpx;
		height: 80rpx;
		border-top: 1rpx solid #BDBDBD;
		display: flex;
		flex-direction: row;
	}

	.income-content-text-button-cancel {
		width: 299rpx;
		height: 80rpx;
		border-right: 1rpx solid #BDBDBD;
		font-size: 32rpx;
		font-weight: 500;
		color: #787878;
		line-height: 80rpx;
		text-align: center;
	}

	.income-content-text-button-ok {
		width: 300rpx;
		height: 80rpx;
		font-size: 32rpx;
		font-weight: 500;
		color: #F39B19;
		line-height: 80rpx;
		text-align: center;
	}

	.income-content-baodi-view {
		width: 527rpx;
		height: 48rpx;
		background-color: #FDE4E4;
		border-radius: 24rpx;
		text-align: center;
		font-size: 24rpx;
		font-weight: 500;
		color: #FF4600;
		line-height: 48rpx;
		margin-bottom: 52rpx;
	}
</style>